home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6491 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.5 KB  |  127 lines

  1. Path: rain.fr!world-net!usenet
  2. From: dgklone@worldnet.net (Denis Glehen)
  3. Newsgroups: comp.lang.c++
  4. Subject: BorlandC - TIListImp class problem or misprogramming
  5. Date: Thu, 08 Feb 1996 23:11:30 GMT
  6. Organization: sct.fr
  7. Message-ID: <4fe0lk$cu3@aldebaran.sct.fr>
  8. NNTP-Posting-Host: client22.sct.fr
  9. X-Newsreader: Forte Free Agent 1.0.82
  10.  
  11. Hi all,
  12.  
  13. i've a little problem with the use of TListImp and LIListImp class
  14. function. 
  15.  
  16. I would like create a list with some data on it. I saw that Borland
  17. purpose a class as it => TListImp class.
  18.  
  19. But, I don't find how make it working.
  20.  
  21. I've a private class Noeud wich contain in X and int Y.
  22. I create constructor and destructor and two small function. Ninit and
  23. Nprint.
  24.  
  25. I want create node Noeud (dynamically) and attach them to the list.
  26. So, i use TIListImp wich seem working with pointer : 
  27.  
  28. class Noeud {
  29.    private:
  30.       int x;
  31.       int y;
  32.    public:
  33.       Noeud(void);
  34.       ~Noeud(void);
  35.       void Ninit(int a,int b);
  36.       void Nprint(void);
  37.    };
  38.  
  39.  
  40. void printN(Noeud *nn)
  41. {
  42.    nn->Nprint();
  43. }
  44.  
  45. // Main function
  46. --------------------------------------------------------------
  47. int OwlMain(int,char **)
  48. {
  49.    PROGRAM Testing("Test");            // define previously, testing it ok !
  50.    TIListImp <Noeud> listNoeud;
  51.  
  52.    Noeud *nnA=NULL;        // create first node
  53.    Noeud *nnB=NULL;        // create second node 
  54.  
  55.    nnA = new Noeud();
  56.    nnB = new Noeud();
  57.  
  58.    nnA->Ninit(1,2);        // init nodes
  59.    nnB->Ninit(2,4);
  60.  
  61.    listNoeud.Add(nnA);     // add node to list
  62.    listNoeud.Add(nnB);
  63.  
  64.  
  65. // want to print them !! ???? error on compilation
  66.  
  67.    listNoeud.ForEach(printN);        
  68.  
  69.  
  70.    delete nnB;
  71.    delete nnA;
  72.  
  73.    return Testing.Run();
  74. }
  75.  
  76.  
  77.  
  78. // PROGRAM class
  79. --------------------------------------------------------------
  80. PROGRAM::PROGRAM(const char far *name) : TApplication(name)
  81. {
  82. }
  83.  
  84. PROGRAM::~PROGRAM(void)
  85. {
  86. }
  87.  
  88.  
  89. // Noeud class
  90. ----------------------------------------------------------------
  91. Noeud::Noeud(void)
  92. {
  93. }
  94.  
  95. Noeud::~Noeud(void)
  96. {
  97. }
  98.  
  99. void Noeud::Ninit(int a,int b)
  100. {
  101.    x = a;
  102.    y = b;
  103. }
  104.  
  105. void Noeud::Nprint(void)
  106. {
  107.    cout << "X=" << x << " Y=" << y;
  108.  
  109. The question is how TIListImp work, I didn't find any docs on it, just
  110. the BorlandC help and it's very small.
  111.  
  112. Is it the good class (TListImp) I must use or is it another class (as
  113. TListImp).
  114.  
  115. And finally, why doesn't it work ? And what mus I do ?
  116.  
  117. Thanks for answering by email at dgklone@worldnet.net
  118.  
  119. Bye - Denis 
  120. --
  121.                    Have a good day
  122.     Klone Development - Denis Glehen - France
  123. Tel : (33) 98 49 07 12      Fax : (33) 98 49 09 41
  124.   Email : dgklone@world-net.sct.fr         :-)
  125.  
  126.